﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;


namespace PapaetisNew
{
    public partial class frmSupplierItems : Form
    {
        public frmSupplierItems()
        {
            InitializeComponent();
        }

        private void tAL_SUPPLIER_ITEMSBindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {
            try
            {
                this.sUPPLIERNAMEITEMTextBox.Text = this.cmbSupplierCode.Text + '-' + this.sUPPLIERNAMETextBox.Text + '-' + this.iTEMCODETextBox.Text + '-' + this.dESCRIPTIONTextBox.Text + '-' + this.pRICETextBox.Text;
                this.Validate();
                this.tAL_SUPPLIER_ITEMSBindingSource.EndEdit();
                this.tableAdapterManager.UpdateAll(this.dsSupplierItems);
                MessageBox.Show("Update successful");
            }
            catch (Exception ex)
            {
                MessageBox.Show("Update failed");

            }
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'suppliers.TAL_SUPPLIER' table. You can move, or remove it, as needed.
            this.tAL_SUPPLIERTableAdapter.Fill(this.suppliers.TAL_SUPPLIER);
            // TODO: This line of code loads data into the 'dsSupplierItems.TAL_SUPPLIER_ITEMS' table. You can move, or remove it, as needed.
            this.tAL_SUPPLIER_ITEMSTableAdapter.Fill(this.dsSupplierItems.TAL_SUPPLIER_ITEMS);

        }

        private void cmbSupplierCode_SelectedIndexChanged(object sender, EventArgs e)
        {

            string s = cmbSupplierCode.Text;
            DataRow foundRow = suppliers.Tables[0].Rows.Find(s);

            if (foundRow != null)
            {
                sUPPLIERNAMETextBox.Text = foundRow[1].ToString();
                // MessageBox.Show(foundRow[1].ToString());
            }
            else
            {
                MessageBox.Show("A row with the primary key of " + s + " could not be found");
            }
  
        ///   sUPPLIERNAMETextBox.Text=  cmbSupplierCode.DataSource(suppliers.TAL_SUPPLIER.Columns[0].ToString() ) ;

        }

        private void sUPPLIERNAMETextBox_TextChanged(object sender, EventArgs e)
        {
           
        }

        private void sUPPLIERNAMEITEMTextBox_TextChanged(object sender, EventArgs e)
        {
            
        }

        private void pRICETextBox_TextChanged(object sender, EventArgs e)
        {
            
        }

        private void tAL_SUPPLIER_ITEMSBindingNavigator_RefreshItems(object sender, EventArgs e)
        {

        }
    }
}
